Copyright: Copyright 1996 Silicon Commander Games


TDIB Component

Properties

Unit

DIB

Description

TDIB components encapsulate a Windows DIB.  TDIB is a non-visual component.  You can display a TDIB on a TDIBDrawingSurface component by using the CopyRect method of the TDIB’s DIBCanvas.  Normally you will associate a TDIB with one or more TDIBSprites.  In this case, the TDIBSprite’s Render method renders the DIB for you when the sprite is updated.

Once the TDIB is loaded with data, it stores the binary image data in the form’s DFM file.  You can load a DIB by accessing its DIBLoadFile or DIBLoadImage properties.  DIBLoadFile enables you to load data from a BMP file.  DIBLoadImage allows you to copy the image from an existing TImage on your form.  In both cases, the physical image data is copied into the TDIB, and the reference to the source of the data is not maintained.

Only the image data for the DIB is saved, not the color table.  To render a DIB with the correct colors, you should create a logical palette using the TColorPalette component.  All of your TDIBs should be created from the same palette.  You then assign this palette to the TDIBDrawingSurface’s ColorPalette property.


Properties

DataLoaded	DIBCanvas	DIBLoadFile

DIBLoadImage	FramesX	FramesY

NumColors	Size


Device Independent Bitmap


DataLoaded Property

Applies To

TDIB

Declaration

property DataLoaded: boolean;

Description

This read-only property is indicator of whether or not the TDIB contains image data.


DIBCanvas Property

Applies To

TDIB

Declaration

property DIBCanvas: TDIBCanvas;

Description

The TDIBCanvas that is associated with the image data of this TDIB.  You can access the image data through this special type of canvas.  You also use the DIBCanvas to render the DIB on a TDIBDrawingSurface.


DIBLoadFile Property

Applies To

TDIB

Declaration

property DIBLoadFile: TFileName;

Description

When you set this property to the file name of a valid BMP file, the file’s image data is loaded into the TDIB.  The reference to the file is not maintained by the TDIB, instead, the TDIB actually stores the binary data on the form’s DFM file.  For this reason, the value of the file name does not persist in this property.


DIBLoadImage Property

Applies To

TDIB

Declaration

property DIBLoadImage: TImage;

Description

When assign an existing TImage to this property, the TImage’s image data is loaded into the TDIB.  The reference to the TImage is not maintained by the TDIB, instead, the TDIB actually stores the binary data on the form’s DFM file.  For this reason, the value of the TImage does not persist in this property.


FramesX Property

Applies To

TDIB

Declaration

property FramesX: integer;

Description

The FramesX property allows you to divide the TDIB’s image data into logical segments.  FramesX contains the number of horizontal frames that are contained in the image.  The only object that uses this information is TDIBSprite.


FramesY Property

Applies To

TDIB

Declaration

property FramesY: integer;

Description

The FramesY property allows you to divide the TDIB’s image data into logical segments.  FramesY contains the number of vertical frames that are contained in the image.  The only object that uses this information is TDIBSprite.


NumColors Property

Applies To

TDIB

Declaration

property NumColors: integer;

Description

The number of colors supported by the DIB.  The current release of TurboSprite supports 8-bit (256 color) DIBs only.


Size Property

Applies To

TDIB

Declaration

property Size: integer;

Description

The number of bytes of image data contained in the DIB.  This information is also available through the TDIB’s DIBCanvas, but is provided here as well for convenience.